package com.aioz.security.controller;


import com.aioz.security.aop.annotation.LogInfoAnnotation;
import com.aioz.security.common.ResponseResult;
import com.aioz.security.entity.Application;
import com.aioz.security.service.impl.ApplicationServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Aioz
 * @since 2022-09-28
 */
@RestController
@RequestMapping("/application")
public class ApplicationController {

    @Resource
    private ApplicationServiceImpl applicationService;

    //求职者向企业申请面试
    @PostMapping("/apply")
    @LogInfoAnnotation
    public ResponseResult apply(@RequestBody Application application){
       return applicationService.apply(application);
    }

    //企业HR查看面试申请
    @LogInfoAnnotation
    @PostMapping("/by/hr/{name}")
    public ResponseResult getApplicationByHr(@PathVariable String name){
        return applicationService.getApplicationByHr(name);
    }

    //查看全部的面试申请
    @LogInfoAnnotation
    @GetMapping("/get/all")
    public ResponseResult getAllApplication(){
        return applicationService.getAllApplication();
    }

    //用户查看自己的面试申请
    @LogInfoAnnotation
    @GetMapping("/get/own/{currentPage}")
    public ResponseResult getOwn(@PathVariable Integer currentPage){
        return applicationService.getOwn(currentPage);
    }

    @PostMapping("/refuse/{applicationId}")
    @LogInfoAnnotation
    public ResponseResult refuseApplication(@PathVariable Integer applicationId){
        return applicationService.refuseApplication(applicationId);
    }

    //搜索投递该企业的申请信息
    @LogInfoAnnotation
    @PostMapping("/like/{username}/{companyId}")
    public ResponseResult likeApplicationByUsername(@PathVariable String username,
                                                    @PathVariable Integer companyId){
        return applicationService.likeApplicationByUsername(username,companyId);
    }

    //搜索投递该企业的申请信息
    @LogInfoAnnotation
    @PostMapping("/get/company/own/{companyId}/{currentPage}")
    public ResponseResult getApplicationsByCompany(@PathVariable Integer companyId,
                                                   @PathVariable Integer currentPage){
        return applicationService.getApplicationsByCompany(companyId,currentPage);
    }
}
